using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Transactions;
using SimpleFS.Core;

namespace SimpleFS.Services.Transactions.Implementations
{
    public abstract class TransactableOperationTemplate : ITransactableOperation
    {
        protected abstract void Operate();

        public abstract void Commit();

        public abstract void Rollback();

        internal IResourceManager resourceManager;

        /// <summary>
        /// Performs actual operation.
        /// </summary>
        public void Execute()
        {
            this.resourceManager.Enlist();

            this.resourceManager.WriteRedoLog(this);
            this.Operate();
            this.resourceManager.WriteUndoLog(this);
        }
    }
}
